home *** CD-ROM | disk | FTP | other *** search
- /* $VER: DMExecOnMany.rexx 1.2 (2.10.98) by J. Tierney
-
- DiskMaster II Execute On Many 1.2
- 10/2/98 J. Tierney
-
- Function: Execute a command on (possibly) many selected files.
-
- Usage: DMExecOnMany.rexx <maximum files> <command>
-
- <maximum files> - If positive: Accept 0 to this many selected files.
- If zero: Accept 0 to 999,999 selected files.
- If -1: Accept 1 to 999,999 selected files.
- If < -1: Accept 1 to Abs(this many) selected files.
-
- <command> - The name of the command to execute, and any options.
-
- Examples:
- DMExecOnMany.rexx 0 SYS:Utilitiess/Visage SHOWINFO WBMONITOR
- - Visage will be run; no files need to be selected.
-
- DMExecOnMany.rexx -3 C:Echo >T:SelectedFiles.txt
- - Up to 3 selected file names will be echoed to T:SelectedFiles.txt.
- There must be at least one file selected.
-
- History:
- - 1.2 (10/2/98):
- - Changed script to use the new improved DirList.
-
- - 1.1 (9/30/97):
- - Added "-1" option for <maximum files>.
- - Limited the command line to 510 characters (<command> will be executed
- multiple times if necessary).
-
- */
-
- OPTIONS RESULTS
-
- PARSE ARG max cmd
-
- SELECT
- WHEN max = 0 THEN DO
- max = 999999
- neednofiles = 1
- END
- WHEN max = -1 THEN DO
- max = 999999
- neednofiles = 0
- END
- WHEN max < -1 THEN DO
- max = ABS(max)
- neednofiles = 0
- END
- WHEN max > 0 THEN neednofiles = 1
- END
-
- cmd = STRIP(cmd, 'B')
- IF cmd = '' THEN EXIT 0
- cmdlen = LENGTH(cmd)
-
-
- line. = ''
- lc = 0
- linelen = cmdlen
- DIRLIST VAR dlist SEL
- DO i = 1 TO dlist.name.0
- l = LENGTH(dlist.name.i)
- linelen = linelen + l + 1
- IF linelen > 510 THEN DO
- lc = lc + 1
- linelen = cmdlen
- END
- line.lc = line.lc dlist.name.i
- END
-
-
- IF neednofiles | line.0 ~= '' THEN DO
- STATUS P
- PRAGMA('D', result)
- DO i = 0 TO lc
- ADDRESS COMMAND cmd || line.i
- END
- DESELECT '*'
- END
-